package mysqltool;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class text {
    Connection connection=null;

    public text() throws SQLException {
        String utl="jdbc:mysql://localhost:3306/studentsdb";
        String name="root";
        String passward="13949271904";
        connection= DriverManager.getConnection(utl,name,passward);
    }
    public int updataworkers(int no,String name,String address) throws SQLException {
        String sql="updata worker set id=?,name=?,address=? where id=?";
        PreparedStatement pstm=connection.prepareStatement(sql);
        pstm.setString(1,name);
        pstm.setString(2,address);
        pstm.setInt(3,no);
        int result=pstm.executeUpdate();
        return result;
    }

    public static void main(String[] args) throws SQLException {
        text res=new text();
        int r=res.updataworkers(1,"张","yy");
        if(r>0){
            System.out.println("修改成功");
        }
    }
}
